New upstream version 0.1.24
authorMatteo F. Vescovi <mfv@debian.org>
Sat, 18 Feb 2017 13:16:36 +0000 (14:16 +0100)
committerMatteo F. Vescovi <mfv@debian.org>
Sat, 18 Feb 2017 13:16:36 +0000 (14:16 +0100)
30 files changed:
AUTHORS
INSTALL
Makefile.in
NEWS
README
babl/babl-cache.c
babl/babl-fish-path.c
babl/babl-fish.c
babl/babl-hash-table.c
babl/babl-version.h
babl/base/pow-24.h
babl/base/util.h
config.guess
config.sub
configure
configure.ac
docs/index-static.html.in
extensions/16bit.c [new file with mode: 0644]
extensions/CIE.c
extensions/Makefile.am
extensions/Makefile.in
extensions/cairo.c
extensions/fast-float.c
extensions/gggl-lies.c
extensions/gggl.c
extensions/gimp-8bit.c
extensions/simple.c
extensions/sse2-float.c
extensions/sse2-int8.c
tools/babl-verify.c

diff --git a/AUTHORS b/AUTHORS
index ae2fec26f193d491e3a43cc3dd2751c390fb2551..01b5dbf7d06420fabec36839dd263ab98802b9a5 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -52,6 +52,9 @@
   <dt>Micheal MurĂ©</dd>
   <dd>portability fixes</dd>
 
+  <dt>Edward E</dt>
+  <dd>win32 platform adaptations</dd>
+
   <dt>Maxime Nicco</dt>
     <dl>HSV color model extension</dl>
   <dt>Teo Mazars</dt>
diff --git a/INSTALL b/INSTALL
index c937773da994f2d4625398874fc35788b69ef6cf..6ec14909ff81c1f79a26f4e7593a2bc64212de86 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-babl 0.1.22
+babl 0.1.24
 
     Dynamic; any to any, pixel format conversion library.
 
@@ -12,10 +12,10 @@ From a released version the following is the expected method of
 installation (or a variation on this theme):
 
      ------------------------------------------------------------
-     foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.22.tar.bz2
-     foo$ tar jxf babl-0.1.22.tar.gz
-     foo$ cd babl-0.1.22
-     foo/babl-0.1.22$ ./configure && make && sudo make install
+     foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.24.tar.bz2
+     foo$ tar jxf babl-0.1.24.tar.gz
+     foo$ cd babl-0.1.24
+     foo/babl-0.1.24$ ./configure && make && sudo make install
      ------------------------------------------------------------
 
 
index 98b34edf45ee178bc20549181bedaf5dd736631a..86bde5639662d6dbc1643db9898ac6fb5cf2f4ab 100644 (file)
@@ -195,7 +195,7 @@ DIST_SUBDIRS = babl extensions tests tools docs
 am__DIST_COMMON = $(srcdir)/INSTALL.in $(srcdir)/Makefile.in \
        $(srcdir)/babl.pc.in $(srcdir)/config.h.in AUTHORS COPYING \
        INSTALL NEWS README TODO compile config.guess config.sub \
-       depcomp install-sh ltmain.sh missing
+       install-sh ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
diff --git a/NEWS b/NEWS
index a885050d816553768b5dd07adf79cffd9c1cee6d..4cf2b21e163e7cb109fd2c87b9ace2447ed500e3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ the news section both in the README and the webpage.
 
 
                                                                           -->
+
+2017-02-01 babl-0.1.24                                              </dt><dd>
+Improvements to profile cache persistance, fast paths that improve actual GIMP
+use on various precisions, use single precision constants for some more of CIE
+computions.
+                                                                    </dd><dt>
 2016-11-05 babl-0.1.22                                              </dt><dd>
 Added cache of profiled conversions, added HCY color model, some precision and
 performance updated for fast paths.
diff --git a/README b/README
index dd22fe7b5afc6110af3fecaae61fbf65f19666dc..38f10d18ddb8b3bb9cc42a2d340a5e5d53d664e9 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Babl-0.1.22
+Babl-0.1.24
 
 Contents
 
@@ -46,8 +46,8 @@ pixel formats.
 
 Download
 
-The latest versioned development version of babl can be found in ftp://
-ftp.gtk.org/pub/babl/.
+The latest versioned development version of babl can be found in https:
+//download.gimp.org/pub/babl/.
 
 Babl uses git. The main repository is hosted by GNOME. It can be
 browsed online and cloned with:
@@ -59,6 +59,10 @@ babl release. If there are significant improvements to babl when a GEGL
 release is done a babl release is most often put out just prior to the
 GEGL release.
 
+2017-02-01 babl-0.1.24
+    Improvements to profile cache persistance, fast paths that improve
+    actual GIMP use on various precisions, use single precision
+    constants for some more of CIE computions.
 2016-11-05 babl-0.1.22
     Added cache of profiled conversions, added HCY color model, some
     precision and performance updated for fast paths.
@@ -2048,6 +2052,8 @@ Simon Budig
     cleanups
 Micheal MurĂ©
     portability fixes
+Edward E
+    win32 platform adaptations
 Maxime Nicco
 
     HSV color model extension
@@ -2069,4 +2075,4 @@ Jon Nordby
 Massimo Valentini
     stability fixes
 
-/babl-0.1.22
+/babl-0.1.24
index 1f0b6f5f68ca31321417a776921c04f79a085d64..5f7b71636f71f744cb4179fd348ed8a3ac943a6a 100644 (file)
  * <http://www.gnu.org/licenses/>.
  */
 
+#ifdef _WIN32
+#include <shlobj.h>
+#endif
+
 #include <time.h>
 #include <sys/stat.h>
 #include "config.h"
@@ -51,7 +55,7 @@ mk_ancestry_iter (const char *path)
             }
         }
     }
-  return -1;
+  return 0;
 }
 
 static int
@@ -77,8 +81,13 @@ static const char *fish_cache_path (void)
   if (getenv ("HOME"))
     sprintf (path, "%s/.cache/babl/babl-fishes", getenv("HOME"));
 #else
-  if (getenv ("TEMP"))
+{
+  char win32path[4096];
+  if (SHGetFolderPathA (NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, win32path) == S_OK)
+    sprintf (path, "%s\\%s\\babl-fishes.txt", win32path, BABL_LIBRARY);
+  else if (getenv ("TEMP"))
     sprintf (path, "%s\\babl-fishes.txt", getenv("TEMP"));
+}
 #endif
 
   if (stat (path, &stat_buf)==0 && S_ISREG(stat_buf.st_mode))
@@ -135,15 +144,32 @@ static int compare_fish_pixels (const void *a, const void *b)
          ((*fb)->fish.processings - (*fa)->fish.processings);
 }
 
+static const char *cache_header (void)
+{
+  static char buf[2048];
+  if (strchr (BABL_GIT_VERSION, ' ')) // we must be building from tarball
+    sprintf (buf, "#%i.%i.%i BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f",
+             BABL_MAJOR_VERSION, BABL_MINOR_VERSION, BABL_MICRO_VERSION,
+             _babl_max_path_len (), _babl_legal_error ());
+  else
+    sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f",
+             BABL_GIT_VERSION,
+             _babl_max_path_len (), _babl_legal_error ());
+  return buf;
+}
+
 void babl_store_db (void)
 {
   BablDb *db = babl_fish_db ();
   int i;
-  FILE *dbfile = fopen (fish_cache_path (), "w");
+  char *tmpp = calloc(8000,1);
+  FILE *dbfile;
+
+  sprintf (tmpp, "%s~", fish_cache_path ());
+  dbfile  = fopen (tmpp, "w");
   if (!dbfile)
     return;
-  fprintf (dbfile, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f\n",
-           BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ());
+  fprintf (dbfile, "%s\n", cache_header ());
 
   /* sort the list of fishes by usage, making next run more efficient -
    * and the data easier to approach as data for targeted optimization
@@ -159,6 +185,9 @@ void babl_store_db (void)
       fprintf (dbfile, "%s----\n", tmp);
   }
   fclose (dbfile);
+
+  rename (tmpp, fish_cache_path());
+  free (tmpp);
 }
 
 static int
@@ -254,10 +283,7 @@ void babl_init_db (void)
         case '#':
           /* if babl has changed in git .. drop whole cache */
           {
-            char buf[2048];
-            sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f",
-               BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ());
-            if (strcmp ( token, buf))
+            if (strcmp ( token, cache_header ()))
             {
               free (contents);
               return;
index 23e775712f7b5b5dc34d8cca48c21a75303dd564..4f169d0b51424283fb1487b120bccbea32c65091 100644 (file)
@@ -21,7 +21,7 @@
 #include "babl-internal.h"
 #include "babl-ref-pixels.h"
 
-#define BABL_TOLERANCE             0.000006
+#define BABL_TOLERANCE             0.000001
 #define BABL_MAX_COST_VALUE        2000000
 #define BABL_HARD_MAX_PATH_LENGTH  8
 #define BABL_MAX_NAME_LEN          1024
@@ -333,6 +333,11 @@ babl_fish_path (const Babl *source,
 
     get_conversion_path (&pc, (Babl *) source, 0, max_path_length ());
 
+    /* second attempt,. at path length + 1*/
+    if (babl->fish_path.conversion_list->count == 0 &&
+        max_path_length () + 1 <= BABL_HARD_MAX_PATH_LENGTH)
+      get_conversion_path (&pc, (Babl *) source, 0, max_path_length () + 1);
+
     babl_in_fish_path--;
     babl_free (pc.current_path);
   }
@@ -341,6 +346,25 @@ babl_fish_path (const Babl *source,
     {
       babl_free (babl);
       babl_mutex_unlock (babl_format_mutex);
+
+#ifndef BABL_UNSTABLE
+      if (debug_conversions)
+#endif
+      {
+        static int warnings = 0;
+        if (warnings++ == 0)
+          fprintf (stderr, 
+"Missing fast-path babl conversion detected, Implementing missing babl fast paths\n"
+"accelerates GEGL, GIMP and other software using babl, warnings are printed on\n"
+"first occurance of formats used where a conversion has to be synthesized\n"
+"programmatically by babl based on format description\n"
+"\n");
+
+        fprintf (stderr, "*WARNING*: missing babl fast path(s) between formats \"%s\" and \"%s\"\n",
+           babl_get_name (source),
+           babl_get_name (destination));
+
+      }
       return NULL;
     }
 
index 76cb53d0cc5f7ad8be23e503ee25b1aff7ad0103..96c69c3b195c81167db460aae4f26d0692c0b33d 100644 (file)
@@ -133,6 +133,8 @@ babl_fish_get_id (const Babl *source,
    * source/destination values. */
   ptrdiff_t id = source - destination;
   /* instances with id 0 won't be inserted into database */
+  id *= ((((size_t)  (source))) % 37);
+
   if (id == 0)
     id = 1;
   return id;
index d507cb228141d19264e52983cb4103aabf53e7e5..e1c2e56088dede1485eae17cc2c0d4ab08a3b49b 100644 (file)
@@ -58,15 +58,11 @@ babl_hash_by_int (BablHashTable *htab,
                   int           id)
 {
   int   hash = 0;
-  int   i;
-
-  for (i = 0; i < sizeof (int); i++)
-  {
-    hash +=  id & 0xFF;
-    hash += (hash << 10);
-    hash ^= (hash >> 6);
-    id >>= 8;
-  }
+  hash +=  id & 0xFF;
+  hash += (hash << 10);
+  hash ^= (hash >> 6);
+  id >>= 8;
+  hash +=  id & 0xFF;
   hash += (hash << 3);
   hash ^= (hash >> 11);
   hash += (hash << 15);
index 11c7b8fac8b818abbffabd97dbf6c4935265104d..9adad13d0e97d0aa7ed91f2a105a65632973cf10 100644 (file)
@@ -34,7 +34,7 @@
 
 #define BABL_MAJOR_VERSION 0
 #define BABL_MINOR_VERSION 1
-#define BABL_MICRO_VERSION 22
+#define BABL_MICRO_VERSION 24
 
 /** Get the version information on the babl library */
 void   babl_get_version (int *major,
index cbd6fd404b9f4a0aed9dd44c769043d2f3493562..5271b409c6efbc3f25ef7024289eb6e58f493b7a 100644 (file)
@@ -78,6 +78,31 @@ babl_pow_1_24 (double x)
   return x*y;
 }
 
+
+#include <stdint.h>
+/* frexpf copied from musl */
+static inline float babl_frexpf(float x, int *e)
+{
+        union { float f; uint32_t i; } y = { x };
+        int ee = y.i>>23 & 0xff;
+
+        if (!ee) {
+                if (x) {
+                        x = babl_frexpf(x*0x1p64, e);
+                        *e -= 64;
+                } else *e = 0;
+                return x;
+        } else if (ee == 0xff) {
+                return x;
+        }
+
+        *e = ee - 0x7e;
+        y.i &= 0x807ffffful;
+        y.i |= 0x3f000000ul;
+        return y.f;
+}
+
+
 //////////////////////////////////////////////
 /* a^b = exp(b*log(a))
  *
@@ -96,7 +121,7 @@ static inline float
 init_newtonf (float x, float exponent, float c0, float c1, float c2)
 {
     int iexp;
-    float y = frexpf(x, &iexp);
+    float y = babl_frexpf(x, &iexp);
     y = 2*y+(iexp-2);
     c1 *= M_LN2*exponent;
     c2 *= M_LN2*M_LN2*exponent*exponent;
index 34725230274738d7b4072792e2aa8ede2f5d1b07..2d346b4bc3d5019604d281f6884a1fdab4e3246e 100644 (file)
@@ -105,4 +105,7 @@ babl_gamma_2_2_to_linearf (float value)
 #else
   #define linear_to_gamma_2_2(value) (pow((value), (1.0F/2.2F)))
   #define gamma_2_2_to_linear(value) (pow((value), 2.2F))
+
+  #define babl_linear_to_gamma_2_2f(value) (powf((value), (1.0f/2.2f)))
+  #define babl_gamma_2_2_to_linearf(value) (powf((value), 2.2f))
 #endif
index 0967f2afa92a80d4afeb6fcf901bf7d55b13434f..2e9ad7fe8189d20ca777d62a38609942e7732c25 100755 (executable)
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-04-02'
+timestamp='2016-10-02'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
        esac
        # The Operating System including object format, if it has switched
-       # to ELF recently, or will in the future.
+       # to ELF recently (or will in the future) and ABI.
        case "${UNAME_MACHINE_ARCH}" in
-           arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
+           earm*)
+               os=netbsdelf
+               ;;
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
                eval $set_cc_for_build
                if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
                        | grep -q __ELF__
@@ -997,6 +1000,9 @@ EOF
        eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
        test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
        ;;
+    mips64el:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
     openrisc*:Linux:*:*)
        echo or1k-unknown-linux-${LIBC}
        exit ;;
@@ -1029,6 +1035,9 @@ EOF
     ppcle:Linux:*:*)
        echo powerpcle-unknown-linux-${LIBC}
        exit ;;
+    riscv32:Linux:*:* | riscv64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
        echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
        exit ;;
@@ -1408,18 +1417,17 @@ esac
 cat >&2 <<EOF
 $0: unable to guess system type
 
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite
+config.guess and config.sub with the latest versions from:
 
   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
 
 config.guess timestamp = $timestamp
 
index 8d39c4ba39fe355d2282cc414828c01b762df133..dd2ca93c6fbe3ea67ea9e67beb1d389045677943 100755 (executable)
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-03-30'
+timestamp='2016-11-04'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -117,7 +117,7 @@ case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
-  kopensolaris*-gnu* | \
+  kopensolaris*-gnu* | cloudabi*-eabi* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@@ -301,6 +301,7 @@ case $basic_machine in
        | open8 | or1k | or1knd | or32 \
        | pdp10 | pdp11 | pj | pjl \
        | powerpc | powerpc64 | powerpc64le | powerpcle \
+       | pru \
        | pyramid \
        | riscv32 | riscv64 \
        | rl78 | rx \
@@ -428,6 +429,7 @@ case $basic_machine in
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
        | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+       | pru-* \
        | pyramid-* \
        | riscv32-* | riscv64-* \
        | rl78-* | romp-* | rs6000-* | rx-* \
@@ -643,6 +645,14 @@ case $basic_machine in
                basic_machine=m68k-bull
                os=-sysv3
                ;;
+       e500v[12])
+               basic_machine=powerpc-unknown
+               os=$os"spe"
+               ;;
+       e500v[12]-*)
+               basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=$os"spe"
+               ;;
        ebmon29k)
                basic_machine=a29k-amd
                os=-ebmon
@@ -1022,7 +1032,7 @@ case $basic_machine in
        ppc-* | ppcbe-*)
                basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
-       ppcle | powerpclittle | ppc-le | powerpc-little)
+       ppcle | powerpclittle)
                basic_machine=powerpcle-unknown
                ;;
        ppcle-* | powerpclittle-*)
@@ -1032,7 +1042,7 @@ case $basic_machine in
                ;;
        ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+       ppc64le | powerpc64little)
                basic_machine=powerpc64le-unknown
                ;;
        ppc64le-* | powerpc64little-*)
@@ -1389,7 +1399,7 @@ case $os in
              | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
              | -chorusos* | -chorusrdb* | -cegcc* \
              | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+             | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
              | -linux-newlib* | -linux-musl* | -linux-uclibc* \
              | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
              | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
@@ -1399,7 +1409,7 @@ case $os in
              | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
              | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
              | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
-             | -onefs* | -tirtos*)
+             | -onefs* | -tirtos* | -phoenix* | -fuchsia*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        -qnx*)
index 0931451ad672219864823ef24bfd520388e8738a..67c251e719ead30700fdd12a327fc55e916211c4 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for babl 0.1.22.
+# Generated by GNU Autoconf 2.69 for babl 0.1.24.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='babl'
 PACKAGE_TARNAME='babl'
-PACKAGE_VERSION='0.1.22'
-PACKAGE_STRING='babl 0.1.22'
+PACKAGE_VERSION='0.1.24'
+PACKAGE_STRING='babl 0.1.24'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1380,7 +1380,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures babl 0.1.22 to adapt to many kinds of systems.
+\`configure' configures babl 0.1.24 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1452,7 +1452,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of babl 0.1.22:";;
+     short | recursive ) echo "Configuration of babl 0.1.24:";;
    esac
   cat <<\_ACEOF
 
@@ -1572,7 +1572,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-babl configure 0.1.22
+babl configure 0.1.24
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1937,7 +1937,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by babl $as_me 0.1.22, which was
+It was created by babl $as_me 0.1.24, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2293,11 +2293,11 @@ ac_config_headers="$ac_config_headers config.h"
 
 BABL_MAJOR_VERSION=0
 BABL_MINOR_VERSION=1
-BABL_MICRO_VERSION=22
+BABL_MICRO_VERSION=24
 BABL_INTERFACE_AGE=1
-BABL_BINARY_AGE=122
-BABL_VERSION=0.1.22
-BABL_REAL_VERSION=0.1.22
+BABL_BINARY_AGE=124
+BABL_VERSION=0.1.24
+BABL_REAL_VERSION=0.1.24
 BABL_API_VERSION=0.1
 
 
@@ -2332,7 +2332,7 @@ fi
 
 
 
-BABL_LIBRARY_VERSION="121:1:121"
+BABL_LIBRARY_VERSION="123:1:123"
 BABL_CURRENT_MINUS_AGE=0
 
 
@@ -2964,7 +2964,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='babl'
- VERSION='0.1.22'
+ VERSION='0.1.24'
 
 
 # Some tools Automake needs.
@@ -13910,7 +13910,7 @@ $as_echo_n "checking whether we can compile half-floating point code... " >&6; }
 int
 main ()
 {
-__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps());
+__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps()); __m128i val2 = _mm_insert_epi64((__m128i)_mm_setzero_ps(), 0, 0);
   ;
   return 0;
 }
@@ -14854,7 +14854,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by babl $as_me 0.1.22, which was
+This file was extended by babl $as_me 0.1.24, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14920,7 +14920,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-babl config.status 0.1.22
+babl config.status 0.1.24
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index 77f9b0c21ba2774470ba2c71ca188b0a9e44d1ec..c15f6896981b3bbed2503e16d0a993ec29d8a9d5 100644 (file)
@@ -14,7 +14,7 @@ AC_PREREQ(2.54)
 
 m4_define([babl_major_version], [0])
 m4_define([babl_minor_version], [1])
-m4_define([babl_micro_version], [22])
+m4_define([babl_micro_version], [24])
 m4_define([babl_real_version],
           [babl_major_version.babl_minor_version.babl_micro_version])
 m4_define([babl_version], [babl_real_version])
@@ -408,7 +408,7 @@ if test "x$enable_mmx" = xyes; then
 
         CFLAGS="$CFLAGS $sse_flag $f16c_flag"
 
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <immintrin.h>],[__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps());])],
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <immintrin.h>],[__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps()); __m128i val2 = _mm_insert_epi64((__m128i)_mm_setzero_ps(), 0, 0);])],
           AC_DEFINE(USE_F16C, 1, [Define to 1 if f16c intrinsics are available.])
           AC_MSG_RESULT(yes)
         ,
index c71f23665290d036481ce91dc9ec55e027a09753..64a12670f6e7473a812888d54759d627d301633c 100644 (file)
     <h2>Download</h2>
 
     <p>The latest versioned development version of babl can be found in
-    <a href='ftp://ftp.gtk.org/pub/babl/'>ftp://ftp.gtk.org/pub/babl/</a>.
+    <a href='https://download.gimp.org/pub/babl/'>https://download.gimp.org/pub/babl/</a>.
     </p>
 
     <p>Babl uses git. The main repository is hosted by GNOME.
diff --git a/extensions/16bit.c b/extensions/16bit.c
new file mode 100644 (file)
index 0000000..96701ef
--- /dev/null
@@ -0,0 +1,103 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2016, Ă˜yvind KolĂ¥s.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdint.h>
+
+#include "babl.h"
+
+#include "base/util.h"
+#include "extensions/util.h"
+
+static inline long
+conv_rgbu16_rgbau16 (unsigned char *src, 
+                     unsigned char *dst, 
+                     long           samples)
+
+
+{
+  uint16_t *src16 = (uint16_t*) src;
+  uint16_t *dst16 = (uint16_t*) dst;
+  long n = samples;
+
+  while (n--)
+    {
+      *dst16++ = *src16++;
+      *dst16++ = *src16++;
+      *dst16++ = *src16++;
+      *dst16++ = 0xffff;
+    }
+
+  return samples;
+}
+
+static inline long
+conv_yu16_yau16 (unsigned char *src, 
+                 unsigned char *dst, 
+                 long           samples)
+
+
+{
+  uint16_t *src16 = (uint16_t*) src;
+  uint16_t *dst16 = (uint16_t*) dst;
+  long n = samples;
+
+  while (n--)
+    {
+      *dst16++ = *src16++;
+      *dst16++ = 0xffff;
+    }
+
+  return samples;
+}
+
+int init (void);
+
+int
+init (void)
+{
+  babl_conversion_new (
+    babl_format ("R'G'B' u16"),
+    babl_format ("R'G'B'A u16"),
+    "linear",
+    conv_rgbu16_rgbau16,
+    NULL);
+
+  babl_conversion_new (
+    babl_format ("Y' u16"),
+    babl_format ("Y'A u16"),
+    "linear",
+    conv_yu16_yau16,
+    NULL);
+
+  babl_conversion_new (
+    babl_format ("RGB u16"),
+    babl_format ("RGBA u16"),
+    "linear",
+    conv_rgbu16_rgbau16,
+    NULL);
+
+  babl_conversion_new (
+    babl_format ("Y u16"),
+    babl_format ("YA u16"),
+    "linear",
+    conv_yu16_yau16,
+    NULL);
+  return 0;
+}
index 2e0aca2609d26ac2fccfa7e9cd92e5ec5f236ff9..e1e2fa747ce3e68ea48167ae964fdc70f5d5a3ae 100644 (file)
@@ -28,8 +28,8 @@
 #define DEGREES_PER_RADIAN (180 / 3.14159265358979323846)
 #define RADIANS_PER_DEGREE (1 / DEGREES_PER_RADIAN)
 
-#define LAB_EPSILON       (216.0 / 24389.0)
-#define LAB_KAPPA         (24389.0 / 27.0)
+#define LAB_EPSILON       (216.0f / 24389.0f)
+#define LAB_KAPPA         (24389.0f / 27.0f)
 
 /* The constants below hard-code the D50-adapted sRGB ICC profile
  * reference white, aka the ICC profile D50 illuminant.
@@ -46,9 +46,9 @@
  * hard-coded D50 ICC profile illuminant values:
  */
 
-#define D50_WHITE_REF_X   0.964202880
-#define D50_WHITE_REF_Y   1.000000000
-#define D50_WHITE_REF_Z   0.824905400
+#define D50_WHITE_REF_X   0.964202880f
+#define D50_WHITE_REF_Y   1.000000000f
+#define D50_WHITE_REF_Z   0.824905400f
 
 
 int init (void);
@@ -444,6 +444,63 @@ cubef (float f)
   return f * f * f;
 }
 
+/* origin: FreeBSD /usr/src/lib/msun/src/s_cbrtf.c */
+/*
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Debugged and optimized by Bruce D. Evans.
+ */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+/* _cbrtf(x)
+ * Return cube root of x
+ */
+
+#include <math.h>
+#include <stdint.h>
+
+static const unsigned
+B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23 */
+B2 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
+
+static inline float _cbrtf(float x)
+{
+       float r,T;
+       union {float f; uint32_t i;} u = {x};
+       uint32_t hx = u.i & 0x7fffffff;
+
+       if (hx >= 0x7f800000)  /* cbrt(NaN,INF) is itself */
+               return x + x;
+
+       /* rough cbrt to 5 bits */
+       if (hx < 0x00800000) {  /* zero or subnormal? */
+               if (hx == 0)
+                       return x;  /* cbrt(+-0) is itself */
+               u.f = x*0x1p24f;
+               hx = u.i & 0x7fffffff;
+               hx = hx/3 + B2;
+       } else
+               hx = hx/3 + B1;
+       u.i &= 0x80000000;
+       u.i |= hx;
+
+       T = u.f;
+       r = T*T*T;
+       T = T*((float)x+x+r)/(x+r+r);
+
+       r = T*T*T;
+       T = T*((float)x+x+r)/(x+r+r);
+
+       return T;
+}
+
 static long
 Yaf_to_Laf (float *src,
             float *dst,
@@ -455,7 +512,7 @@ Yaf_to_Laf (float *src,
     {
       float yr = src[0];
       float a  = src[1];
-      float L  = yr > LAB_EPSILON ? 116.0 * cbrtf (yr) - 16 : LAB_KAPPA * yr;
+      float L  = yr > LAB_EPSILON ? 116.0f * _cbrtf (yr) - 16 : LAB_KAPPA * yr;
 
       dst[0] = L;
       dst[1] = a;
@@ -467,6 +524,7 @@ Yaf_to_Laf (float *src,
   return samples;
 }
 
+
 static long
 rgbf_to_Labf (float *src,
               float *dst,
@@ -484,9 +542,9 @@ rgbf_to_Labf (float *src,
       float yr = 0.22248840f / D50_WHITE_REF_Y * r + 0.71690369f / D50_WHITE_REF_Y * g + 0.06060791f / D50_WHITE_REF_Y * b;
       float zr = 0.01391602f / D50_WHITE_REF_Z * r + 0.09706116f / D50_WHITE_REF_Z * g + 0.71392822f / D50_WHITE_REF_Z * b;
 
-      float fx = xr > LAB_EPSILON ? cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f;
-      float fy = yr > LAB_EPSILON ? cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f;
-      float fz = zr > LAB_EPSILON ? cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f;
+      float fx = xr > LAB_EPSILON ? _cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f;
+      float fy = yr > LAB_EPSILON ? _cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f;
+      float fz = zr > LAB_EPSILON ? _cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f;
 
       float L = 116.0f * fy - 16.0f;
       float A = 500.0f * (fx - fy);
@@ -521,9 +579,9 @@ rgbaf_to_Labaf (float *src,
       float yr = 0.22248840f / D50_WHITE_REF_Y * r + 0.71690369f / D50_WHITE_REF_Y * g + 0.06060791f / D50_WHITE_REF_Y * b;
       float zr = 0.01391602f / D50_WHITE_REF_Z * r + 0.09706116f / D50_WHITE_REF_Z * g + 0.71392822f / D50_WHITE_REF_Z * b;
 
-      float fx = xr > LAB_EPSILON ? cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f;
-      float fy = yr > LAB_EPSILON ? cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f;
-      float fz = zr > LAB_EPSILON ? cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f;
+      float fx = xr > LAB_EPSILON ? _cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f;
+      float fy = yr > LAB_EPSILON ? _cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f;
+      float fz = zr > LAB_EPSILON ? _cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f;
 
       float L = 116.0f * fy - 16.0f;
       float A = 500.0f * (fx - fy);
@@ -1044,7 +1102,6 @@ types_u16 (void)
 
   babl_type_new (
     "CIE u16 ab",
-    "id", "CIE u8 ab",
     "integer",
     "unsigned",
     "bits", 16,
index 0aeb9b79d4c791a1185c0c1a79ac97f8da00c4ea..923ddada8d9d6098a76f42a5b1f7b7093fd517a2 100644 (file)
@@ -15,6 +15,7 @@ AM_CPPFLAGS = \
 
 extdir = $(libdir)/babl-@BABL_API_VERSION@
 ext_LTLIBRARIES = \
+       16bit.la        \
        cairo.la        \
        CIE.la          \
     float-half.la   \
index 48926ce08b3ec5465e1b068f61ed10c912b107c7..a696fd6759a2874feb58abe48eb751b7c83cfd8a 100644 (file)
@@ -133,13 +133,16 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(extdir)"
 LTLIBRARIES = $(ext_LTLIBRARIES)
-CIE_la_LIBADD =
-am_CIE_la_OBJECTS = CIE.lo
-CIE_la_OBJECTS = $(am_CIE_la_OBJECTS)
+16bit_la_LIBADD =
+16bit_la_SOURCES = 16bit.c
+16bit_la_OBJECTS = 16bit.lo
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
+CIE_la_LIBADD =
+am_CIE_la_OBJECTS = CIE.lo
+CIE_la_OBJECTS = $(am_CIE_la_OBJECTS)
 HSL_la_LIBADD =
 am_HSL_la_OBJECTS = HSL.lo
 HSL_la_OBJECTS = $(am_HSL_la_OBJECTS)
@@ -255,8 +258,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \
-       $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \
+SOURCES = 16bit.c $(CIE_la_SOURCES) $(HSL_la_SOURCES) \
+       $(HSV_la_SOURCES) $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \
        $(float_half_la_SOURCES) $(float_la_SOURCES) \
        $(gegl_fixups_la_SOURCES) $(gggl_lies_la_SOURCES) \
        $(gggl_table_lies_la_SOURCES) $(gggl_table_la_SOURCES) \
@@ -266,8 +269,8 @@ SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \
        $(sse2_int16_la_SOURCES) $(sse2_int8_la_SOURCES) \
        $(sse4_int8_la_SOURCES) $(two_table_la_SOURCES) \
        $(ycbcr_la_SOURCES)
-DIST_SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \
-       $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \
+DIST_SOURCES = 16bit.c $(CIE_la_SOURCES) $(HSL_la_SOURCES) \
+       $(HSV_la_SOURCES) $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \
        $(float_half_la_SOURCES) $(float_la_SOURCES) \
        $(gegl_fixups_la_SOURCES) $(gggl_lies_la_SOURCES) \
        $(gggl_table_lies_la_SOURCES) $(gggl_table_la_SOURCES) \
@@ -466,6 +469,7 @@ AM_CPPFLAGS = \
 
 extdir = $(libdir)/babl-@BABL_API_VERSION@
 ext_LTLIBRARIES = \
+       16bit.la        \
        cairo.la        \
        CIE.la          \
     float-half.la   \
@@ -587,6 +591,9 @@ clean-extLTLIBRARIES:
          rm -f $${locs}; \
        }
 
+16bit.la: $(16bit_la_OBJECTS) $(16bit_la_DEPENDENCIES) $(EXTRA_16bit_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(16bit_la_OBJECTS) $(16bit_la_LIBADD) $(LIBS)
+
 CIE.la: $(CIE_la_OBJECTS) $(CIE_la_DEPENDENCIES) $(EXTRA_CIE_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(CIE_la_OBJECTS) $(CIE_la_LIBADD) $(LIBS)
 
@@ -662,6 +669,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/16bit.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CIE.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HSL.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HSV.Plo@am__quote@
index 56413a2918cf55dcb98971e15c55476006acfd0d..5569ab693b980c9141ecdb8d2ee16cee95c926b4 100644 (file)
@@ -29,16 +29,17 @@ static inline long
 conv_rgba8_cairo24_le (unsigned char *src, unsigned char *dst, long samples)
 {
   long n = samples;
+  uint32_t *srci = (void *)src;
+  uint32_t *dsti = (void *)dst;
+
   while (n--)
     {
-      unsigned char red   = *src++;
-      unsigned char green = *src++;
-      unsigned char blue  = *src++;
-      *dst++ = blue;
-      *dst++ = green;
-      *dst++ = red;
-      *dst++ = 255;
-      src++;
+      uint32_t orig = *srci++;
+      uint32_t green_alpha = (orig & 0x0000ff00);
+      uint32_t red_blue    = (orig & 0x00ff00ff);
+      uint32_t red         = red_blue << 16;
+      uint32_t blue        = red_blue >> 16;
+      *dsti++              = green_alpha | red | blue | 0xff000000;
     }
   return samples;
 }
@@ -58,8 +59,11 @@ conv_rgb8_cairo24_le (unsigned char *src, unsigned char *dst, long samples)
       *dst++ = 255;
     }
   return samples;
+
+
 }
 
+#if 0
 static inline long
 conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -78,6 +82,28 @@ conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long sampl
     }
   return samples;
 }
+#else
+
+static inline long
+conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+  uint32_t *srci = (void *)src;
+  uint32_t *dsti = (void *)dst;
+
+  while (n--)
+    {
+      uint32_t orig = *srci++;
+      uint32_t green_alpha = (orig & 0xff00ff00);
+      uint32_t red_blue    = (orig & 0x00ff00ff);
+      uint32_t red         = red_blue << 16;
+      uint32_t blue        = red_blue >> 16;
+      *dsti++              = green_alpha | red | blue;
+    }
+  return samples;
+}
+#endif
+
 
 static inline long
 conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
@@ -94,12 +120,128 @@ conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
       *dst++ = div_255 (blue  * alpha);
       *dst++ = div_255 (green * alpha);
       *dst++ = div_255 (red   * alpha);
+      *dst++ = alpha;
+    }
+  return samples;
+}
+
+static inline long
+conv_rgb8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+  while (n--)
+    {
+      unsigned char red    = *src++;
+      unsigned char green  = *src++;
+      unsigned char blue   = *src++;
+
+      *dst++ = blue;
+      *dst++ = green;
+      *dst++ = red;
+      *dst++ = 0xff;
+    }
+  return samples;
+}
+
+
+
+
+static inline long
+conv_yA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+  while (n--)
+    {
+      unsigned char gray   = *src++;
+      unsigned char alpha  = *src++;
+      unsigned char val = div_255 (gray * alpha);
+
 #undef div_255
+
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = val;
       *dst++ = alpha;
     }
   return samples;
 }
 
+static inline long
+conv_yA16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+  uint16_t *ssrc = (void*) src;
+  while (n--)
+    {
+      float alpha = (ssrc[1]) / 65535.0f;
+      int val = (ssrc[0] * alpha) * (0xff / 65535.0f ) + 0.5f;
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = (alpha * 0xff + 0.5f);
+      ssrc+=2;
+    }
+  return samples;
+}
+
+static inline long
+conv_y8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+  while (n--)
+    {
+      unsigned char val = *src++;
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = 0xff;
+    }
+  return samples;
+}
+
+static inline long
+conv_y16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+  uint16_t *s16 = (void*)src;
+  while (n--)
+    {
+#define div_257(a) ((((a)+128)-(((a)+128)>>8))>>8)
+      uint16_t v16 = *s16++;
+      unsigned char val = div_257(v16);
+#undef dib_257
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = val;
+      *dst++ = 0xff;
+    }
+  return samples;
+}
+
+static long
+conv_rgbA_gamma_float_cairo32_le (unsigned char *src,
+                                  unsigned char *dst,
+                                  long           samples)
+{
+  float *fsrc = (float *) src;
+  unsigned char *cdst = (unsigned char *) dst;
+  int n = samples;
+
+  while (n--)
+    {
+      int val = fsrc[2] * 255.0f  + 0.5f;
+      *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+      val = fsrc[1] * 255.0f + 0.5f;
+      *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+      val = fsrc[0] * 255.0f + 0.5f;
+      *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+      val = fsrc[3] * 255.0f + 0.5f;
+      *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+      fsrc+=4;
+    }
+  return samples;
+}
+
 static long
 conv_rgbafloat_cairo32_le (unsigned char *src,
                            unsigned char *dst,
@@ -145,6 +287,48 @@ conv_rgbafloat_cairo32_le (unsigned char *src,
   return samples;
 }
 
+
+static long
+conv_yafloat_cairo32_le (unsigned char *src,
+                         unsigned char *dst,
+                         long           samples)
+{
+  float *fsrc = (float *) src;
+  unsigned char *cdst = (unsigned char *) dst;
+  int n = samples;
+
+  while (n--)
+    {
+      float gray   = *fsrc++;
+      float alpha  = *fsrc++;
+      if (alpha >= 1.0)
+      {
+        int val = babl_linear_to_gamma_2_2f (gray) * 0xff + 0.5f;
+        val = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+        *cdst++ = val;
+        *cdst++ = val;
+        *cdst++ = val;
+        *cdst++ = 0xff;
+      }
+      else if (alpha <= 0.0)
+      {
+        (*(uint32_t*)cdst)=0;
+        cdst+=4;
+      }
+      else
+      {
+        float balpha = alpha * 0xff;
+        int val = babl_linear_to_gamma_2_2f (gray) * balpha + 0.5f;
+        val = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+        *cdst++ = val;
+        *cdst++ = val;
+        *cdst++ = val;
+        *cdst++ = balpha + 0.5f;
+      }
+    }
+  return samples;
+}
+
 int
 init (void)
 {
@@ -175,14 +359,34 @@ init (void)
         babl_component ("PAD"),
         NULL
       );
-
       babl_conversion_new (babl_format ("R'aG'aB'aA u8"), f32, "linear", 
                            conv_rgbA8_premul_cairo32_le, NULL);
+
       babl_conversion_new (babl_format ("R'G'B'A u8"), f32, "linear",
                            conv_rgbA8_cairo32_le, NULL);
 
+
+      babl_conversion_new (babl_format ("R'G'B' u8"), f32, "linear",
+                           conv_rgb8_cairo32_le, NULL);
+
+      babl_conversion_new (babl_format ("Y'A u8"), f32, "linear",
+                           conv_yA8_cairo32_le, NULL);
+      babl_conversion_new (babl_format ("Y'A u16"), f32, "linear",
+                           conv_yA16_cairo32_le, NULL);
+
+
+      babl_conversion_new (babl_format ("Y' u8"), f32, "linear",
+                           conv_y8_cairo32_le, NULL);
+      babl_conversion_new (babl_format ("Y' u16"), f32, "linear",
+                           conv_y16_cairo32_le, NULL);
+
       babl_conversion_new (babl_format ("RGBA float"), f32, "linear",
                            conv_rgbafloat_cairo32_le, NULL);
+      babl_conversion_new (babl_format ("YA float"), f32, "linear",
+                           conv_yafloat_cairo32_le, NULL);
+
+      babl_conversion_new (babl_format ("R'aG'aB'aA float"), f32, "linear",
+                           conv_rgbA_gamma_float_cairo32_le, NULL);
 
       babl_conversion_new (babl_format ("R'G'B'A u8"), f24, "linear", 
                            conv_rgba8_cairo24_le, NULL);
@@ -211,6 +415,8 @@ init (void)
         babl_component ("B'"),
         NULL
       );
+
+      /* formats are registered - but no fast paths, this will be slow */
     }
   babl_format_new (
     "name", "cairo-A8",
index 162b3f5c961da43fa75ad1dbc4ed0e1e344d1054..163ffe86add99a416069ccfcb613119c9af8188d 100644 (file)
@@ -411,6 +411,47 @@ conv_rgbaF_linear_rgbA8_gamma (unsigned char *src,
   return samples;
 }
 
+static INLINE long
+conv_yaF_linear_rgbA8_gamma (unsigned char *src, 
+                             unsigned char *dst, 
+                             long           samples)
+{
+   float *fsrc = (float *) src;
+   uint8_t *cdst = (uint8_t *) dst;
+   int n = samples;
+
+   while (n--)
+     {
+       float gray = *fsrc++;
+       float alpha = *fsrc++;
+       if (alpha >= 1.0)
+       {
+         int val = linear_to_gamma_2_2_lut (gray) * 0xff + 0.5f;
+         *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+         *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+         *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+         *cdst++ = 0xff;
+       }
+       else if (alpha <= 0.0)
+       {
+         *((uint32_t*)(cdst))=0;
+            cdst+=4;
+       }
+       else
+       {
+         float balpha = alpha * 0xff;
+         int val = linear_to_gamma_2_2_lut (gray) * balpha + 0.5f;
+         *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+         *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+         *cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
+         *cdst++ = balpha + 0.5f;
+       }
+     }
+  return samples;
+}
+
+
+
 static long
 conv_rgbaF_linear_rgbA8_gamma_cairo (unsigned char *src, 
                                      unsigned char *dst, 
@@ -580,6 +621,13 @@ int init (void);
 int
 init (void)
 {
+  const Babl *yaF_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+
   const Babl *rgbaF_linear = babl_format_new (
     babl_model ("RGBA"),
     babl_type ("float"),
@@ -646,6 +694,8 @@ init (void)
     babl_component ("B'"),
     NULL);
 
+  return 0;  // XXX: the fast paths registered here doesn't correctly
+             //      clamp negative values - disabling for now
   {
     float f;
     float a;
@@ -689,7 +739,7 @@ init (void)
   o (rgbaF_gamma,  rgbaF_linear);
   o (rgbF_linear,  rgbF_gamma);
   o (rgbF_gamma,   rgbF_linear);
-
+  o (yaF_linear,   rgbA8_gamma);
   return 0;
 }
 
index 5d50f5bffe10c71d8f0a684730a932d2c27a6ee8..3d1627f3bf690dd7750d08e898ac483bd562349f 100644 (file)
@@ -250,7 +250,7 @@ conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
 }
 
 #define conv_rgbAF_rgbAD     conv_rgbaF_rgbaD
-#define conv_rgbAD_rgbAD     conv_rgbaD_rgbaF
+#define conv_rgbAD_rgbAF     conv_rgbaD_rgbaF
 #define conv_rgbAF_rgbA16    conv_rgbaF_rgba16
 #define conv_gF_g16          conv_F_16
 #define conv_gAF_gA16        conv_gaF_ga16
@@ -418,6 +418,29 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
+
+static long
+conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      *(float *) dst = 1.0;
+      dst           += 4;
+      src           += 4;
+    }
+  return samples;
+}
+
+#define conv_gF_rgbAF conv_gF_rgbaF
+
 static long
 conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -725,6 +748,15 @@ init (void)
     babl_component ("Ba"),
     babl_component ("A"),
     NULL);
+  const Babl *rgbAD = babl_format_new (
+    babl_model ("RaGaBaA"),
+    babl_type ("double"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
+
   const Babl *rgbA16 = babl_format_new (
     babl_model ("RaGaBaA"),
     babl_type ("u16"),
@@ -819,6 +851,8 @@ init (void)
 
   o (rgbaF, rgbaD);
   o (rgbaD, rgbaF);
+  o (rgbAF, rgbAD);
+  o (rgbAD, rgbAF);
   o (rgbaF, rgba8);
   o (rgba8, rgbaF);
   o (rgbaF, rgba16);
@@ -840,6 +874,8 @@ init (void)
   o (gaF, ga8);
   o (gAF, gA8);
   o (gF, g8);
+  o (gF, rgbAF);
+  o (gF, rgbaF);
   o (ga8, gaF);
   o (gA8, gAF);
   o (g8, gF);
index c4b8ce40f34d6f96433d0c54f1c9b4e1af21e4d2..b01659ffbb9fe73f397534e304fa0fb8f8481bee 100644 (file)
@@ -607,6 +607,28 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
+static long
+conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      *(float *) dst = 1.0;
+      dst           += 4;
+      src           += 4;
+    }
+  return samples;
+}
+
+#define conv_gF_rgbAF conv_gF_rgbaF
+
 /*
    static long
    conv_rgb8_rgbaF (unsigned char *src,
@@ -1102,6 +1124,8 @@ init (void)
   o (gF, gaF);
   o (gF, gAF);
   o (gF, rgbF);
+  o (gF, rgbaF);
+  o (gF, rgbAF);
   o (gaF, rgbaF);
   o (gAF, rgbAF);
   o (rgbaF, rgb8);
index d3e952250a8b43cdda5ee3c52896cc73cb7295d5..55bd95c5ebf0e6060cf9100b1569325292d6ab0a 100644 (file)
@@ -228,6 +228,24 @@ conv_ga8_gamma_2_2_gaF_linear (unsigned char *src,
   return samples;
 }
 
+static INLINE long
+conv_ga8_gamma_2_2_rgba8_gamma_2_2 (unsigned char *src,
+                                    unsigned char *dst,
+                                    long           samples)
+{
+  long   n = samples;
+
+  while (n--)
+    {
+      *dst++ = *src;
+      *dst++ = *src;
+      *dst++ = *src++;
+      *dst++ = *src++;
+    }
+
+  return samples;
+}
+
 static INLINE long
 conv_ga8_linear_rgbaF_linear (unsigned char *src,
                               unsigned char *dst,
@@ -496,6 +514,8 @@ init (void)
   o (ga8_linear, rgbaF_linear);
   o (ga8_gamma_2_2, rgbaF_linear);
 
+  o (ga8_gamma_2_2, rgba8_gamma_2_2);
+
   o (g8_linear, gF_linear);
   o (g8_gamma_2_2, gF_linear);
   o (g8_linear, rgbaF_linear);
index bde77854cb3dec69d8f154d400029c602a8399cb..1430ab1404b3274c0f922c0f4e159a02ca5c63e3 100644 (file)
@@ -4,29 +4,42 @@
 
 int init (void);
 
+
 static inline long
-float_to_u8 (unsigned char *src_char, unsigned char *dst, long samples)
+float_to_u8_x1 (unsigned char *src_char, unsigned char *dst, long samples)
 {
   float *src = (float *)src_char;
   long n = samples;
   while (n--)
     {
       float r = src[0];
-      float g = src[1];
-      float b = src[2];
-      float a = src[3];
-            
       dst[0] = (r >= 1.0f) ? 0xFF : ((r <= 0.0f) ? 0x0 : 0xFF * r + 0.5f);
-      dst[1] = (g >= 1.0f) ? 0xFF : ((g <= 0.0f) ? 0x0 : 0xFF * g + 0.5f);
-      dst[2] = (b >= 1.0f) ? 0xFF : ((b <= 0.0f) ? 0x0 : 0xFF * b + 0.5f);
-      dst[3] = (a >= 1.0f) ? 0xFF : ((a <= 0.0f) ? 0x0 : 0xFF * a + 0.5f);
-      
-      dst += 4;
-      src += 4;
+      dst += 1;
+      src += 1;
     }
   return samples;
 }
 
+static inline long
+float_to_u8_x4 (unsigned char *src_char, unsigned char *dst, long samples)
+{
+  return float_to_u8_x1 (src_char, dst, samples * 4);
+}
+
+static inline long
+float_to_u8_x3 (unsigned char *src_char, unsigned char *dst, long samples)
+{
+  return float_to_u8_x1 (src_char, dst, samples * 3);
+}
+
+static inline long
+float_to_u8_x2 (unsigned char *src_char, unsigned char *dst, long samples)
+{
+  return float_to_u8_x1 (src_char, dst, samples * 2);
+}
+
+
+
 static inline long
 float_pre_to_u8_pre (unsigned char *src_char, unsigned char *dst, long samples)
 {
@@ -59,18 +72,56 @@ float_pre_to_u8_pre (unsigned char *src_char, unsigned char *dst, long samples)
 }
 
 static inline long
-float_to_u16 (unsigned char *src_char, unsigned char *dst_char, long samples)
+float_to_u16_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
 {
   float *src    = (float *)src_char;
   uint16_t *dst = (uint16_t *)dst_char;
   long n = samples;
+  while (n--)
+    {
+      float r = src[0];
+      dst[0] = (r >= 1.0f) ? 0xFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFF * r + 0.5f);
+      dst += 1;
+      src += 1;
+    }
+  return samples;
+}
+static inline long
+float_to_u16_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  return float_to_u16_x1 (src_char, dst_char, samples * 2);
+}
+static inline long
+float_to_u16_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  return float_to_u16_x1 (src_char, dst_char, samples * 3);
+}
+static inline long
+float_to_u16_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  return float_to_u16_x1 (src_char, dst_char, samples * 4);
+}
+
+static inline long
+float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  float *src = (float *)src_char;
+  uint16_t *dst = (uint16_t *)dst_char;
+  long n = samples;
   while (n--)
     {
       float r = src[0];
       float g = src[1];
       float b = src[2];
       float a = src[3];
-            
+      
+      if (a > 1.0f) {
+        r /= a;
+        g /= a;
+        b /= a;
+        a /= a;
+      }
+      
       dst[0] = (r >= 1.0f) ? 0xFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFF * r + 0.5f);
       dst[1] = (g >= 1.0f) ? 0xFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFF * g + 0.5f);
       dst[2] = (b >= 1.0f) ? 0xFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFF * b + 0.5f);
@@ -83,10 +134,10 @@ float_to_u16 (unsigned char *src_char, unsigned char *dst_char, long samples)
 }
 
 static inline long
-float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long samples)
+float_pre_to_u32_pre (unsigned char *src_char, unsigned char *dst_char, long samples)
 {
   float *src = (float *)src_char;
-  uint16_t *dst = (uint16_t *)dst_char;
+  uint32_t *dst = (uint32_t *)dst_char;
   long n = samples;
   while (n--)
     {
@@ -102,10 +153,10 @@ float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long sam
         a /= a;
       }
       
-      dst[0] = (r >= 1.0f) ? 0xFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFF * r + 0.5f);
-      dst[1] = (g >= 1.0f) ? 0xFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFF * g + 0.5f);
-      dst[2] = (b >= 1.0f) ? 0xFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFF * b + 0.5f);
-      dst[3] = (a >= 1.0f) ? 0xFFFF : ((a <= 0.0f) ? 0x0 : 0xFFFF * a + 0.5f);
+      dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f);
+      dst[1] = (g >= 1.0f) ? 0xFFFFFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFFFFFF * g + 0.5f);
+      dst[2] = (b >= 1.0f) ? 0xFFFFFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFFFFFF * b + 0.5f);
+      dst[3] = (a >= 1.0f) ? 0xFFFFFFFF : ((a <= 0.0f) ? 0x0 : 0xFFFFFFFF * a + 0.5f);
       
       dst += 4;
       src += 4;
@@ -113,6 +164,135 @@ float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long sam
   return samples;
 }
 
+
+static inline long
+float_to_u32_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  float *src    = (float *)src_char;
+  uint32_t *dst = (uint32_t *)dst_char;
+  long n = samples;
+  while (n--)
+    {
+      float r = src[0];
+            
+      dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f);
+      
+      dst += 1;
+      src += 1;
+    }
+  return samples;
+}
+static inline long
+float_to_u32_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  return float_to_u32_x1 (src_char, dst_char, samples * 2);
+}
+static inline long
+float_to_u32_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  return float_to_u32_x1 (src_char, dst_char, samples * 3);
+}
+static inline long
+float_to_u32_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  return float_to_u32_x1 (src_char, dst_char, samples * 4);
+}
+
+
+static inline long
+u32_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  uint32_t *src = (uint32_t *)src_char;
+  float *dst    = (float *)dst_char;
+  long n = samples;
+  while (n--)
+    {
+      dst[0] = src[0] / 4294967295.0f;
+      dst ++;
+      src ++;
+    }
+  return samples;
+}
+
+static inline long
+u32_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  u32_to_float (src_char, dst_char, samples * 4);
+  return samples;
+}
+
+static inline long
+u32_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  u32_to_float (src_char, dst_char, samples * 3);
+  return samples;
+}
+
+
+static inline long
+u32_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  u32_to_float (src_char, dst_char, samples * 2);
+  return samples;
+}
+
+
+static inline long
+u16_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  uint16_t *src = (uint16_t *)src_char;
+  float *dst    = (float *)dst_char;
+  long n = samples;
+  while (n--)
+    {
+      dst[0] = src[0] / 65535.0f;
+      dst ++;
+      src ++;
+    }
+  return samples;
+}
+
+static inline long
+u16_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  u16_to_float (src_char, dst_char, samples * 4);
+  return samples;
+}
+
+static inline long
+u16_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  u16_to_float (src_char, dst_char, samples * 3);
+  return samples;
+}
+
+
+static inline long
+u16_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  u16_to_float (src_char, dst_char, samples * 2);
+  return samples;
+}
+
+static inline long
+yau16_rgbaf (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+  uint16_t *src = (uint16_t *)src_char;
+  float *dst    = (float *)dst_char;
+  long n = samples;
+  while (n--)
+    {
+      dst[0] = src[0] / 65535.0f;
+      dst[1] = src[0] / 65535.0f;
+      dst[2] = src[0] / 65535.0f;
+      dst[3] = src[1] / 65535.0f;
+      dst +=4;
+      src +=2;
+    }
+  return samples;
+}
+
+
 int
 init (void)
 {
@@ -120,12 +300,42 @@ init (void)
   babl_conversion_new (babl_format ("R'G'B'A float"),
                        babl_format ("R'G'B'A u8"),
                       "linear", 
-                       float_to_u8,
+                       float_to_u8_x4,
                        NULL);
   babl_conversion_new (babl_format ("RGBA float"),
                        babl_format ("RGBA u8"),
                       "linear", 
-                       float_to_u8,
+                       float_to_u8_x4,
+                       NULL);
+  babl_conversion_new (babl_format ("R'G'B' float"),
+                       babl_format ("R'G'B' u8"),
+                      "linear", 
+                       float_to_u8_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("RGB float"),
+                       babl_format ("RGB u8"),
+                      "linear", 
+                       float_to_u8_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("Y'A float"),
+                       babl_format ("Y'A u8"),
+                      "linear", 
+                       float_to_u8_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("YA float"),
+                       babl_format ("YA u8"),
+                      "linear", 
+                       float_to_u8_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("YA float"),
+                       babl_format ("YA u8"),
+                      "linear", 
+                       float_to_u8_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y' float"),
+                       babl_format ("Y' u8"),
+                      "linear", 
+                       float_to_u8_x1,
                        NULL);
   babl_conversion_new (babl_format ("R'aG'aB'aA float"),
                        babl_format ("R'aG'aB'aA u8"),
@@ -142,12 +352,43 @@ init (void)
   babl_conversion_new (babl_format ("R'G'B'A float"),
                        babl_format ("R'G'B'A u16"),
                       "linear", 
-                       float_to_u16,
+                       float_to_u16_x4,
                        NULL);
   babl_conversion_new (babl_format ("RGBA float"),
                        babl_format ("RGBA u16"),
                       "linear", 
-                       float_to_u16,
+                       float_to_u16_x4,
+                       NULL);
+
+  babl_conversion_new (babl_format ("R'G'B' float"),
+                       babl_format ("R'G'B' u16"),
+                      "linear", 
+                       float_to_u16_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("RGB float"),
+                       babl_format ("RGB u16"),
+                      "linear", 
+                       float_to_u16_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("Y'A float"),
+                       babl_format ("Y'A u16"),
+                      "linear", 
+                       float_to_u16_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("YA float"),
+                       babl_format ("YA u16"),
+                      "linear", 
+                       float_to_u16_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y' float"),
+                       babl_format ("Y' u16"),
+                      "linear", 
+                       float_to_u16_x1,
+                       NULL);
+  babl_conversion_new (babl_format ("Y float"),
+                       babl_format ("Y u16"),
+                      "linear", 
+                       float_to_u16_x1,
                        NULL);
   babl_conversion_new (babl_format ("R'aG'aB'aA float"),
                        babl_format ("R'aG'aB'aA u16"),
@@ -160,5 +401,147 @@ init (void)
                        float_pre_to_u16_pre,
                        NULL);
 
+
+  /* float and u32 */
+  babl_conversion_new (babl_format ("R'G'B'A float"),
+                       babl_format ("R'G'B'A u32"),
+                      "linear", 
+                       float_to_u32_x4,
+                       NULL);
+  babl_conversion_new (babl_format ("RGBA float"),
+                       babl_format ("RGBA u32"),
+                      "linear", 
+                       float_to_u32_x4,
+                       NULL);
+  babl_conversion_new (babl_format ("R'G'B' float"),
+                       babl_format ("R'G'B' u32"),
+                      "linear", 
+                       float_to_u32_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("RGB float"),
+                       babl_format ("RGB u32"),
+                      "linear", 
+                       float_to_u32_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("Y'A float"),
+                       babl_format ("Y'A u32"),
+                      "linear", 
+                       float_to_u32_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("YA float"),
+                       babl_format ("YA u32"),
+                      "linear", 
+                       float_to_u32_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y' float"),
+                       babl_format ("Y' u32"),
+                      "linear", 
+                       float_to_u32_x1,
+                       NULL);
+  babl_conversion_new (babl_format ("Y float"),
+                       babl_format ("Y u32"),
+                      "linear", 
+                       float_to_u32_x1,
+                       NULL);
+  babl_conversion_new (babl_format ("R'aG'aB'aA float"),
+                       babl_format ("R'aG'aB'aA u32"),
+                      "linear", 
+                       float_pre_to_u32_pre,
+                       NULL);
+  babl_conversion_new (babl_format ("RaGaBaA float"),
+                       babl_format ("RaGaBaA u32"),
+                      "linear", 
+                       float_pre_to_u32_pre,
+                       NULL);
+  babl_conversion_new (babl_format ("YA u32"),
+                       babl_format ("YA float"),
+                      "linear", 
+                       u32_to_float_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y'A u32"),
+                       babl_format ("Y'A float"),
+                      "linear", 
+                       u32_to_float_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y u32"),
+                       babl_format ("Y float"),
+                      "linear", 
+                       u32_to_float,
+                       NULL);
+  babl_conversion_new (babl_format ("Y' u32"),
+                       babl_format ("Y' float"),
+                      "linear", 
+                       u32_to_float,
+                       NULL);
+  babl_conversion_new (babl_format ("RGBA u32"),
+                       babl_format ("RGBA float"),
+                      "linear", 
+                       u32_to_float_x4,
+                       NULL);
+  babl_conversion_new (babl_format ("R'G'B'A u32"),
+                       babl_format ("R'G'B'A float"),
+                      "linear", 
+                       u32_to_float_x4,
+                       NULL);
+
+  babl_conversion_new (babl_format ("RGB u32"),
+                       babl_format ("RGB float"),
+                      "linear", 
+                       u32_to_float_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("R'G'B' u32"),
+                       babl_format ("R'G'B' float"),
+                      "linear", 
+                       u32_to_float_x3,
+                       NULL);
+
+
+
+  babl_conversion_new (babl_format ("YA u16"),
+                       babl_format ("YA float"),
+                      "linear", 
+                       u16_to_float_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y'A u16"),
+                       babl_format ("Y'A float"),
+                      "linear", 
+                       u16_to_float_x2,
+                       NULL);
+  babl_conversion_new (babl_format ("Y u16"),
+                       babl_format ("Y float"),
+                      "linear", 
+                       u16_to_float,
+                       NULL);
+  babl_conversion_new (babl_format ("Y' u16"),
+                       babl_format ("Y' float"),
+                      "linear", 
+                       u16_to_float,
+                       NULL);
+  babl_conversion_new (babl_format ("RGBA u16"),
+                       babl_format ("RGBA float"),
+                      "linear", 
+                       u16_to_float_x4,
+                       NULL);
+  babl_conversion_new (babl_format ("R'G'B'A u16"),
+                       babl_format ("R'G'B'A float"),
+                      "linear", 
+                       u16_to_float_x4,
+                       NULL);
+
+  babl_conversion_new (babl_format ("RGB u16"),
+                       babl_format ("RGB float"),
+                      "linear", 
+                       u16_to_float_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("R'G'B' u16"),
+                       babl_format ("R'G'B' float"),
+                      "linear", 
+                       u16_to_float_x3,
+                       NULL);
+  babl_conversion_new (babl_format ("Y'A u16"),
+                       babl_format ("R'G'B'A float"),
+                      "linear", 
+                       yau16_rgbaf,
+                       NULL);
   return 0;
 }
index 72463eee929ebe42b4b183d3200452866c98d178..71fa008f2104758dd590385b99511748b3d5c728 100644 (file)
@@ -296,7 +296,7 @@ gamma_2_2_to_linear_sse2 (__v4sf x)
 }
 
 #define GAMMA_RGBA(func, munge) \
-static long \
+static inline long \
 func (const float *src, float *dst, long samples)\
 {\
   int i = samples;\
@@ -353,6 +353,14 @@ func (const float *src, float *dst, long samples)\
 GAMMA_RGBA(conv_rgbaF_linear_rgbaF_gamma, linear_to_gamma_2_2_sse2)
 GAMMA_RGBA(conv_rgbaF_gamma_rgbaF_linear, gamma_2_2_to_linear_sse2)
 
+static long conv_rgbaF_linear_rgbAF_gamma (const float *src, float *dst, long samples)
+{
+  float *tmp = alloca (sizeof(float)*4*samples);
+  conv_rgbaF_linear_rgbaF_gamma (src, tmp, samples);
+  conv_rgbaF_linear_rgbAF_linear (tmp, dst, samples);
+  return samples;
+}
+
 #define YA_APPLY(load, store, convert) \
 { \
   __v4sf yyaa0, yyaa1; \
@@ -637,6 +645,12 @@ init (void)
                           conv_rgbaF_linear_rgbAF_linear,
                           NULL);
                           
+      babl_conversion_new(rgbaF_linear, 
+                          rgbAF_gamma,
+                          "linear",
+                          conv_rgbaF_linear_rgbAF_gamma,
+                          NULL);
+
       /* Which of these is faster varies by CPU, and the difference
        * is big enough that it's worthwhile to include both and
        * let them fight it out in the babl benchmarks.
index 67ff579fd3a4f7458231a9dc0b748663142f8574..5353de6cb6ad8c39cb908e10aff215abab70e5ab 100644 (file)
@@ -146,6 +146,12 @@ conv_rgbaF_rgba8 (const float *src, uint8_t *dst, long samples)
   return conv_yF_y8 (src, dst, samples * 4) / 4;
 }
 
+static long
+conv_rgbAF_rgbA8 (const float *src, uint8_t *dst, long samples)
+{
+  return conv_yF_y8 (src, dst, samples * 4) / 4;
+}
+
 #endif
 
 int init (void);
@@ -154,6 +160,40 @@ int
 init (void)
 {
 #if defined(USE_SSE2)
+
+  const Babl *rgbAF_linear = babl_format_new (
+    babl_model ("RaGaBaA"),
+    babl_type ("float"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbA8_linear = babl_format_new (
+    babl_model ("RaGaBaA"),
+    babl_type ("u8"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbAF_gamma = babl_format_new (
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("float"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbA8_gamma = babl_format_new (
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("u8"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
+
   const Babl *rgbaF_linear = babl_format_new (
     babl_model ("RGBA"),
     babl_type ("float"),
@@ -268,6 +308,7 @@ init (void)
   if ((babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_SSE2))
     {
       CONV(rgbaF, rgba8);
+      CONV(rgbAF, rgbA8);
       CONV(rgbF,  rgb8);
       CONV(yaF,   ya8);
       CONV(yF,    y8);
index 80174db50e88c759a55c37f624e5756abda2313f..5a1a44717b98686921c3728886bffb511a846352 100644 (file)
@@ -1,18 +1,49 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include "babl/babl.h"
+#include "../config.h"
+#include "babl/babl-internal.h"
 
 int main (int argc, char **argv)
 {
-  if (argc != 3)
+  int final = 0;
+  const Babl *fish;
+  if (argc < 3)
   {
     fprintf (stderr, "need two args, from and to babl-formats\n");
     return -1;
   }
+  if (argc == 4)
+    final = 1;
+
+  if (!final)
+  {
   putenv ("BABL_DEBUG_CONVERSIONS" "=" "1");
   putenv ("BABL_TOLERANCE"         "=" "100000.0");
+  }
+
   babl_init ();
-  babl_fish (babl_format(argv[1]), babl_format (argv[2]));
+
+  fish = babl_fish (babl_format(argv[1]), babl_format (argv[2]));
+  if (!fish)
+    return -1;
+
+  if (final)
+  switch (fish->class_type)
+  {
+    case BABL_FISH:
+      fprintf (stderr, "%s\n", babl_get_name (fish));
+      break;
+    case BABL_FISH_PATH:
+      fprintf (stderr, "chosen %s to %s: steps: %i error: %f cost: %f\n", argv[1], argv[2], fish->fish_path.conversion_list->count, fish->fish.error, fish->fish_path.cost);
+        for (int i = 0; i < fish->fish_path.conversion_list->count; i++)
+          {
+            fprintf (stderr, "\t%s\n",
+                      babl_get_name(fish->fish_path.conversion_list->items[i]  ));
+          }
+      break;
+  }
+
+
   babl_exit ();
 
   return 0;